var t = require("../../../utils/themeSkin/skinBehavior"), a = getApp();

Page({
    behaviors: [ t ],
    data: {
        minDate: new Date().getTime(),
        maxDate: new Date().getTime(),
        defaultDate: new Date(),
        defaultDates: new Date(),
        monthCont: 0,
        yearCont: 0,
        param: null,
        clockNum: 3,
        now: "",
        sign_status: !1,
        sign_total: "",
        continue_days: "",
        cumulative: "",
        sign_log: [],
        sign_name: "",
        sharedata: {},
        showYear: new Date().getFullYear(),
        showMonth: new Date().getMonth(),
        date: "",
        show: !1,
        user_name: "",
        uid: "",
        avatar_image: "",
        show_list: [],
        signedList: [],
        m: "",
        w: "",
        src: "",
        signlog: "",
        isshow: "",
        obj: [],
        tapnow: !0
    },
    onLoad: function(t) {
        this.getSign(), this.getData(1), this.getnewDate();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    signnow: function(t) {
        var e = this;
        if (e.data.tapnow) if (this.data.sign_status) wx.showToast({
            title: "今日已经" + this.data.sign_name,
            icon: "none"
        }); else {
            e.setData({
                tapnow: !1
            });
            var n = a.getNetAddresss("plugin.sign.Frontend.Modules.Sign.Controllers.sign.sign");
            a._getNetWork({
                url: n,
                success: function(t) {
                    1 == t.data.result ? (wx.showLoading({
                        title: "加载中",
                        mask: !0
                    }), e.selectComponent("#calendar").getSign(), e.getSign(), e.getnewDate(), wx.navigateTo({
                        url: "/packageA/member/signrecord/signrecord"
                    })) : 0 == t.data.result && (wx.showToast({
                        icon: "none",
                        title: t.data.msg,
                        duration: 1500
                    }), setTimeout(function() {
                        e.setData({
                            tapnow: !0
                        });
                    }, 1500));
                }
            });
        } else console.log("点击限制！！！");
    },
    initShare: function() {
        var t = this, e = a.getNetAddresss("member.member.wxJsSdkConfig");
        a._postNetWork({
            url: e,
            showToastIn: !1,
            data: _url,
            success: function(a) {
                1 == a.result && t.share(response.data);
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getSign: function() {
        var t = this, e = a.getNetAddresss("plugin.sign.Frontend.Modules.Sign.Controllers.sign-log.index");
        a._getNetWork({
            url: e,
            success: function(a) {
                1 == a.data.result ? (wx.hideLoading(), wx.setStorage({
                    key: "sign_log",
                    data: a.data.data.sign_log
                }), t.setData({
                    sign_status: a.data.data.sign_status,
                    sign_total: a.data.data.sign_total,
                    continue_days: a.data.data.continue_days,
                    cumulative: a.data.data.cumulative,
                    sign_log: a.data.data.sign_log,
                    sign_name: a.data.data.sign_name,
                    signedList: a.data.data.sign_log,
                    user_name: a.data.data.member.username,
                    uid: a.data.data.member.uid,
                    avatar_image: a.data.data.member.avatar_image,
                    show_list: a.data.data.show_list
                }), wx.setNavigationBarColor({
                    frontColor: "#ffffff",
                    backgroundColor: t.data.themeBaseColor,
                    animation: {
                        duration: 400,
                        timingFunc: "easeIn"
                    }
                }), wx.setNavigationBarTitle({
                    title: t.data.sign_name
                }), wx.setStorage({
                    key: "cumulative",
                    data: a.data.data.cumulative
                })) : wx.showToast({
                    title: a.data.msg,
                    icon: "none"
                });
            }
        });
    },
    gosignInfo: function() {
        wx.navigateTo({
            url: "/packageA/member/signrecord/signrecord"
        });
    },
    onClickRight: function() {
        wx.navigateTo({
            url: "/packageA/member/signrules/signrules"
        });
    },
    getnewDate: function() {
        var t = new Date(this.data.year, this.data.month, 0);
        this.setData({
            m: t.getDate()
        });
        for (var a = t.getDate(), e = [], n = 1; n <= a; n++) e.push({
            day: n
        });
        this.setData({
            obj: e
        });
        var s = {
            month: this.data.month
        };
        this.getsigninfo(s);
        var i = new Date(this.data.year, this.data.month - 1, 1).getDay();
        this.setData({
            w: 14.27 * i
        });
    },
    put: function() {
        if (this.data.month <= 1) this.setData({
            year: this.data.year - 1,
            month: 12
        }); else {
            var t = this.data.month;
            this.setData({
                month: t - 1
            });
        }
        var a = {
            month: this.data.month
        };
        this.getsigninfo(a), this.getnewDate();
    },
    getsigninfo: function(t) {
        var e = this, n = a.getNetAddresss("plugin.sign.Frontend.Modules.Sign.Controllers.sign-log.index");
        a._postNetWork({
            url: n,
            showToastIn: !1,
            data: t,
            success: function(t) {
                e.setData({
                    signlog: t.data.data.sign_log
                });
                for (var a = e.data.obj, n = new Date().getFullYear(), s = t.data.data.sign_log, i = 0; i < a.length; i++) for (var o = 0; o < s.length; o++) a[i].day - 1 == s[o] && e.data.year == n && (a[i].bool = !0);
                e.setData({
                    obj: a
                });
            }
        });
    },
    add: function() {
        var t = this.data.month;
        if (this.data.month >= 12) {
            var a = this.data.year;
            this.setData({
                year: a + 1,
                month: 1
            });
        } else {
            var e = t;
            this.setData({
                month: e + 1
            });
        }
        this.getnewDate();
    },
    getData: function(t) {
        var a = new Date(), e = a.getFullYear(), n = a.getMonth() + 1, s = a.getDate(), i = a.getHours(), o = a.getMinutes(), g = a.getSeconds();
        n >= 1 && n <= 9 && (n = "0" + n), s >= 0 && s <= 9 && (s = "0" + s), i >= 0 && i <= 9 && (i = "0" + i), 
        o >= 0 && o <= 9 && (o = "0" + o), g >= 0 && g <= 9 && (g = "0" + g);
        var r = "";
        if ("year" == t) return r = e;
        if ("month" == t) return r = e + "-" + n;
        r = e + "-" + n + "-" + s + " " + i + " : " + o + " : " + g;
        var d = this.data.now;
        d = r, this.setData({
            now: d
        });
    },
    onConfirm: function(t) {
        this.setData({
            show: !1,
            date: this.formatDate(t.detail)
        });
    },
    onClose: function() {
        this.setData({
            show: !1
        });
    },
    handleChangeMonth: function(t) {
        t.detail.date;
    },
    change: function() {
        this.selectComponent(".calendar").setData({
            todayStyle: "is-signed"
        }), this.setData({
            signedList: [ "2022/9/1", "2022/9/20", "2022/9/21", "2022/9/22", "2022/8/8", "2022/9/27" ]
        });
    }
});